package cc.messcat.web.system;

import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cc.messcat.common.constant.CommonConstant;
import cc.messcat.common.model.ResponseBean;
import cc.messcat.entity.workingPlayer.WorkingPlayer;
import cc.messcat.service.workingplayer.WorkingplayerService;

/**
 * 帮扶单位
 * 
 * @author John
 *
 */
@Controller
@RequestMapping("/working")
public class WorkingplayerController {

	@Autowired
	public WorkingplayerService workingplayerService;
	
	
	//查询
	@RequestMapping(value = "/findAllworkingplayer" , method = RequestMethod.POST)
	@ResponseBody
	public Object findAllworkingplayer(HttpServletResponse response,Model model) throws Exception {		
		List<WorkingPlayer> resultList = workingplayerService.retrieveAllworking();
	return new ResponseBean(CommonConstant.SUCCESS_CODE_200, CommonConstant.MSG_FIND_SUCCESS, resultList);
	}
	
	
	//添加
		@RequestMapping(value = "/addworkingplayer", method = RequestMethod.POST)
		@ResponseBody
		public Object addworkingplayer(WorkingPlayer workingPlayer)throws Exception{
			Date date=new Date();
			/*workingPlayer.setAffiliation("123");
			workingPlayer.setEnd_Time(date);
			workingPlayer.setFirst_Secretary("123123");
			workingPlayer.setStart_Times(date);
			workingPlayer.setTechnical_Expertise("杨");*/
			workingplayerService.addworking(workingPlayer);
		return new ResponseBean(CommonConstant.SUCCESS_CODE_200, CommonConstant.MSG_ADD_SUCCESS,workingPlayer);
		}
	
	//修改
		@RequestMapping(value = "/updateworkingplayer", method = RequestMethod.POST)
		@ResponseBody
		public Object updateworkingplayer(WorkingPlayer workingPlayer)throws Exception{
			workingplayerService.modifyHelpu(workingPlayer);
		return new ResponseBean(CommonConstant.SUCCESS_CODE_200, CommonConstant.MSG_UPDATE_SUCCESS,workingPlayer);
			}	
		
	//删除
		@RequestMapping(value = "/delectworkingplayer/{id}", method = RequestMethod.POST)
		@ResponseBody
		public Object delecthelppeson(@PathVariable Long id) throws Exception {
			workingplayerService.removeworking(id);
		return new ResponseBean(CommonConstant.SUCCESS_CODE_200, CommonConstant.MSG_DELETE_SUCCESS,id);
			}	
}
